'''
Created on 2012-12-16

@author: j
'''
from cache import WhoisCache 
from cache import WhoisCacheSync 
from cache import WhoisCacheThread

if __name__ == '__main__':
    import sys
    try:
        ip = sys.argv[1]
    except IndexError:
        print 'Usage: %s ip' % sys.argv[0]
    else:
        wc = WhoisCacheThread('whohis.dat')
#        wc = WhoisCacheSync('whohis.dat')
#        wc = WhoisCache('whohis.dat')
        wc.clear()

        print wc.country(ip)
        if isinstance(wc, WhoisCacheThread):
            wc.join()
            print wc.country(ip)
